package com.siwei.mes.entity.laboratory;

import cn.dev33.satoken.stp.StpUtil;
import com.siwei.mes.config.UidUtils;
import com.siwei.mes.enums.ExperimentStatusEnum;
import com.siwei.mes.enums.GenerateCodeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 * 试验台账(Experiment)实体类
 */
@Data
@Accessors(chain = true)
@Table(name = "pk_experiment")
@ApiModel(value = "Experiment", description = "试验台账")
public class XhExperiment implements Serializable {
    private static final long serialVersionUID = 199063996171873048L;
    @Id
    @ApiModelProperty(value = "试验台账主键ID", name = "id")
    private Long id;
    /**
     * 试验编号
     */
    @Column(name = "experiment_no")
    @ApiModelProperty(value = "试验编号", name = "experimentNo")
    private String experimentNo;

    @Column(name = "check_type")
    @ApiModelProperty(value = "检查类型 1-快检 2-批检")
    private Integer checkType;

    @ApiModelProperty(value = "配合比")
    private String phb;

    /**
     * 报告编号
     */
    @Column(name = "report_no")
    @ApiModelProperty(value = "报告编号", name = "reportNo")
    private String reportNo;
    /**
     * 试验状态  试验状态  0-待接收  1-待取样  2-试验中 3-已完成 4-已拒绝
     */
    @Column(name = "experiment_status")
    @ApiModelProperty(value = "试验状态  0-待接收  1-待取样  2-试验中 3-已完成 4-已拒绝", name = "experimentStatus")
    private Integer experimentStatus;
    /**
     * 1-水泥 2-粉煤灰 3-矿渣粉 4-粗骨料 5-细骨料 6-外加剂 7-混凝土
     */
    @Column(name = "experiment_type")
    @ApiModelProperty(value = "1-水泥 2-粉煤灰 3-矿渣粉 4-粗骨料 5-细骨料 6-外加剂 7-混凝土", name = "experimentType")
    private Integer experimentType;
    /**
     * 委托原因 字典code  （entrust_reason）
     */
    @Column(name = "entrust_reason_code")
    @ApiModelProperty(value = "委托原因 字典code  （entrust_reason）", name = "entrustReasonCode")
    private String entrustReasonCode;
    /**
     * 委托原因 字典名称
     */
    @Column(name = "entrust_reason_name")
    @ApiModelProperty(value = "委托原因 字典名称", name = "entrustReasonName")
    private String entrustReasonName;
    /**
     * 委托人id
     */
    @Column(name = "entrust_person_id")
    @ApiModelProperty(value = "委托人id", name = "entrustPersonId")
    private Long entrustPersonId;
    /**
     * 委托人名称
     */
    @Column(name = "entrust_person_name")
    @ApiModelProperty(value = "委托人名称", name = "entrustPersonName")
    private String entrustPersonName;
    /**
     * 委托时间
     */
    @Column(name = "entrust_time")
    @ApiModelProperty(value = "委托时间", name = "entrustTime")
    private Date entrustTime;
    /**
     * 委托试验
     */
    @Column(name = "entrust_experiment")
    @ApiModelProperty(value = "委托试验", name = "entrustExperiment")
    private String entrustExperiment;
    /**
     * 样品等级
     */
    @Column(name = "sample_level")
    @ApiModelProperty(value = "样品等级", name = "sampleLevel")
    private String sampleLevel;

    @Column(name = "materials_name")
    @ApiModelProperty(value = "原材料名称")
    private String materialsName;

    @Column(name = "materials_specs")
    @ApiModelProperty(value = "原材料规格")
    private String materialsSpecs;
    /**
     * 代表数量
     */
    @Column(name = "behalf_number")
    @ApiModelProperty(value = "代表数量", name = "behalfNumber")
    private Double behalfNumber;
    /**
     * 试验依据
     */
    @Column(name = "experiment_gist")
    @ApiModelProperty(value = "试验依据", name = "experimentGist")
    private String experimentGist;
    /**
     * 判断依据
     */
    @Column(name = "judge_gist")
    @ApiModelProperty(value = "判断依据", name = "judgeGist")
    private String judgeGist;
    /**
     * 主要仪器设备
     */
    @Column(name = "equipment")
    @ApiModelProperty(value = "主要仪器设备", name = "equipment")
    private String equipment;
    /**
     * 温度
     */
    @Column(name = "temperature")
    @ApiModelProperty(value = "温度", name = "temperature")
    private String temperature;
    /**
     * 湿度
     */
    @Column(name = "humidness")
    @ApiModelProperty(value = "湿度", name = "humidness")
    private String humidness;
    /**
     * 试验人id
     */
    @Column(name = "experiment_person_id")
    @ApiModelProperty(value = "试验人id", name = "experimentPersonId")
    private Long experimentPersonId;
    /**
     * 试验人名称
     */
    @Column(name = "experiment_person_name")
    @ApiModelProperty(value = "试验人名称", name = "experimentPersonName")
    private String experimentPersonName;
    /**
     * 试验时间
     */
    @Column(name = "experiment_time")
    @ApiModelProperty(value = "试验时间", name = "experimentTime")
    private Date experimentTime;
    /**
     * 校核人id
     */
    @Column(name = "check_person_id")
    @ApiModelProperty(value = "校核人id", name = "checkPersonId")
    private Long checkPersonId;
    /**
     * 校核人名称
     */
    @Column(name = "check_person_name")
    @ApiModelProperty(value = "校核人名称", name = "checkPersonName")
    private String checkPersonName;
    /**
     * 校核时间
     */
    @Column(name = "check_time")
    @ApiModelProperty(value = "校核时间", name = "checkTime")
    private Date checkTime;
    /**
     * 批准人id
     */
    @Column(name = "approve_person_id")
    @ApiModelProperty(value = "批准人id", name = "approvePersonId")
    private Long approvePersonId;
    /**
     * 批准人名称
     */
    @Column(name = "approve_person_name")
    @ApiModelProperty(value = "批准人名称", name = "approvePersonName")
    private String approvePersonName;
    /**
     * 批准时间
     */
    @Column(name = "approve_time")
    @ApiModelProperty(value = "批准时间", name = "approveTime")
    private Date approveTime;
    /**
     * 是否合格 1-合格 2-不合格
     */
    @Column(name = "is_qualified")
    @ApiModelProperty(value = "是否合格 1-合格 2-不合格", name = "isQualified")
    private Integer isQualified;
    /**
     * 结论
     */
    @Column(name = "conclusion")
    @ApiModelProperty(value = "结论", name = "conclusion")
    private String conclusion;
    /**
     * 备注
     */
    @Column(name = "remark")
    @ApiModelProperty(value = "备注", name = "remark")
    private String remark;
    /**
     * 创建人
     */
    @Column(name = "creater")
    @ApiModelProperty(value = "创建人", name = "creater")
    private Long creater;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间", name = "createTime")
    private Date createTime;
    /**
     * 修改人
     */
    @Column(name = "updater")
    @ApiModelProperty(value = "修改人", name = "updater")
    private Long updater;
    /**
     * 更新时间
     */
    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间", name = "updateTime")
    private Date updateTime;
    /**
     * 是否删除  1-删除
     */
    @Column(name = "is_del")
    @ApiModelProperty(value = "是否删除  1-删除", name = "isDel")
    private Integer isDel;

    /**
     * 接收人id
     */
    @Column(name = "accept_person_id")
    @ApiModelProperty(value = "接收人id", name = "acceptPersonId")
    private Long acceptPersonId;
    /**
     * 接收人名称
     */
    @Column(name = "accept_person_name")
    @ApiModelProperty(value = "接收人名称", name = "acceptPersonName")
    private String acceptPersonName;
    /**
     * 接收时间
     */
    @Column(name = "accept_time")
    @ApiModelProperty(value = "接收时间", name = "acceptTime")
    private Date acceptTime;
    /**
     * 取样人id
     */
    @Column(name = "sampling_person_id")
    @ApiModelProperty(value = "取样人id", name = "samplingPersonId")
    private Long samplingPersonId;
    /**
     * 取样人名称
     */
    @Column(name = "sampling_person_name")
    @ApiModelProperty(value = "取样人名称", name = "samplingPersonName")
    private String samplingPersonName;
    /**
     * 取样时间
     */
    @Column(name = "sampling_time")
    @ApiModelProperty(value = "取样时间", name = "samplingTime")
    private Date samplingTime;
    /**
     * 完成人id
     */
    @Column(name = "finish_person_id")
    @ApiModelProperty(value = "完成人id", name = "finishPersonId")
    private Long finishPersonId;
    /**
     * 完成人名称
     */
    @Column(name = "finish_person_name")
    @ApiModelProperty(value = "完成人名称", name = "finishPersonName")
    private String finishPersonName;
    /**
     * 完成时间
     */
    @Column(name = "finish_time")
    @ApiModelProperty(value = "完成时间", name = "finishTime")
    private Date finishTime;
    /**
     * 拒绝人id
     */
    @Column(name = "refuse_person_id")
    @ApiModelProperty(value = "拒绝人id", name = "refusePersonId")
    private Long refusePersonId;
    /**
     * 拒绝人名称
     */
    @Column(name = "refuse_person_name")
    @ApiModelProperty(value = "拒绝人名称", name = "refusePersonName")
    private String refusePersonName;
    /**
     * 拒绝时间
     */
    @Column(name = "refuse_time")
    @ApiModelProperty(value = "拒绝时间", name = "refuseTime")
    private Date refuseTime;

    @Column(name = "molding_time")
    @ApiModelProperty(value = "成型时间")
    private Date moldingTime;

    @Column(name = "curing_mode")
    @ApiModelProperty(value = "养护条件")
    private String curingMode;

    @Column(name = "entrust_state")
    @ApiModelProperty(value = "委托任务状态 等待检测 0  已检测 1")
    private String entrustState;

    @Column(name = "sample_no")
    @ApiModelProperty(value = "对应上海协会试验台账id")
    private String sampleNo;


    @Transient
    @ApiModelProperty(value = "任务单号")
    private String FRwdh;

    @Transient
    @ApiModelProperty(value = "多个状态集合")
    private List<Integer> experimentStatusList;

    @Transient
    @ApiModelProperty(value = "多个试验类型")
    private List<Integer> experimentTypeList;

    @Transient
    @ApiModelProperty(value = "多个委托原因code")
    private List<String> entrustReasonCodeList;

    @Transient
    @ApiModelProperty(value = "关键字搜索")
    private String keyword;

    @Transient
    @ApiModelProperty(value = "开始时间")
    private String startTime;

    @Transient
    @ApiModelProperty(value = "结束时间")
    private String endTime;

    @Transient
    @ApiModelProperty(value = "委托任务状态不为等待检测")
    private String entrustStateNot;

    @Transient
    @ApiModelProperty(value = "是否查询的已完成的 0-未完成  1-已完成")
    private Integer isFinish;

    @Transient
    @ApiModelProperty(value = "实时统计出来的代表数量(混凝土)")
    private Double realBehalfNumber;

    @Transient
    @ApiModelProperty(value = "实时统计出来的代表数量(原材料)")
    private Double realMaterialNumber;

    @Transient
    @ApiModelProperty(value = "查询类型 1 选择样品")
    private String queryType;


    // WtConsign
    @Transient
    private String conSignId;


    @Transient
    private String kindId;

    @Transient
    private String itemId;

    @Transient
    private String reportId;

    @Transient
    private String examConclusion;

    @Transient
    private String projectName;

    @Transient
    private String examQuan;

    @Transient
    private String examKind;

    @Transient
    private String projectId;

    @Transient
    private String totalPrices;

    @Transient
    private String witnessNo;

    @Transient
    private String samplingNo;

    @Transient
    private Date samplingDate;

    @Transient
    private String getreportType;


    //WtSample
    @Transient
    private String examParameter;

    @Transient
    private String examParameterCn;


    @Transient
    private String sampleId;

    @Transient
    private String specId;

    @Transient
    private String gradeId;

    @Transient
    private String status;

    @Transient
    private String sampleStatus;

    @Transient
    private String sampleModify;

    @Transient
    private String prince;

    @Transient
    private String uploadFlag;

    @Transient
    private String delegateQuan;

    @Transient
    private String recordCertificate;

    @Transient
    private String ProduceFactory;

    @Transient
    private String delegateQuanUnit;

    @Transient
    private String importId;

    @Transient
    private String isProduce;


    public XhExperiment init(boolean isCreate) {
        this.setUpdater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null)
                .setUpdateTime(new Date());
        if (isCreate) {
            this.setCreater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null)
                    .setCreateTime(new Date()).setExperimentStatus(ExperimentStatusEnum.WAIT_ACCEPT.getCode())
                    .setIsDel(0).setExperimentNo(UidUtils.genNo(GenerateCodeEnum.EXPERIMENT.getCode()));
        }
        return this;
    }

    public XhExperiment phbInit(boolean isCreate) {
        this.setUpdateTime(new Date());
        if (isCreate) {
            this.setCreateTime(new Date()).setExperimentStatus(ExperimentStatusEnum.WAIT_ACCEPT.getCode())
                    .setIsDel(0).setExperimentNo(UidUtils.genNo(GenerateCodeEnum.EXPERIMENT.getCode()));
        }
        return this;
    }

    public XhExperiment tcInit(boolean isCreate) {
        this.setUpdateTime(new Date());
        if (isCreate) {
            this.setCreateTime(new Date()).setExperimentStatus(ExperimentStatusEnum.WAIT_ACCEPT.getCode())
                    .setIsDel(0).setExperimentNo(UidUtils.genNo(GenerateCodeEnum.EXPERIMENT.getCode()));
        }
        return this;
    }
}
